﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

namespace GovernmentOfficeProject.LevelDataAccessModel
{
    public class Entity_USER_User
    {
        public Entity_USER_User()
        {

        }
        public Entity_USER_User(decimal PuserID,List<Entity_USER_Role> Proles,List<Entity_USER_Department> Pdepts,
                                            string PloginName,string PloginPWD,string PrealName,string Psex,string PmobilePhone,
                                            string PTelePhony,string Pemail,string Pqq,string PofficeAddress,string PhomeAddress,
                                            string PlastLoginTime,decimal PcreateUID,string PcreateDate,decimal PmodifyUID,
                                            string PmodifyDate,decimal PrecordState,string Pbk1,string Pbk2,string Pbk3,string Pbk4,string Pbk5)
        {
            UserID = PuserID;
            Roles = Proles;
            Depts = Pdepts;
            LoginName = PloginName;
            LoginPassword = PloginPWD;
            RealName = PrealName;
            Sex = Psex;
            MobilePhone = PmobilePhone;
            Telephony = PTelePhony;
            Email = Pemail;
            QQ = Pqq;
            OfficeAddress = PofficeAddress;
            HomeAddress = PhomeAddress;
            LastLoginTime = PlastLoginTime;
            CreateUserID = PcreateUID;
            CreateDateTime = PcreateDate;
            ModifyUserID = PmodifyUID;
            ModifyDateTime = PmodifyDate;
            RecordStatus = PrecordState;
            Backup1 = Pbk1;
            Backup2 = Pbk2;
            Backup3 = Pbk3;
            Backup4 = Pbk4;
            Backup5 = Pbk5;
        }
               
        private decimal userID = -1;                         //用户唯一编号.
        public decimal UserID
        {     
            get { return userID; }
            set { userID = value; }
        }

        private List<Entity_USER_Role> roles;           //一个用户可以所属多个角色，一个角色组有多个用户，多对多关系。            
        public List<Entity_USER_Role> Roles 
        {
            get { return roles; }
            set { roles = value; }
        }

        private List<Entity_USER_Department> depts;     //一个用户可以所属多个部门，一个部门下有多个用户，多对多关系。
        public List<Entity_USER_Department> Depts
        {
            get { return depts; }
            set { depts = value; }
        }
        public string DeptNames { get; set; }

        private string loginName;                       //用户登录名.
        public string LoginName
        {
            get { return loginName; }
            set { loginName = value; }
        }

        private string loginPassword;                   //用户登录密码.
        public string LoginPassword
        {
            get { return loginPassword; }
            set { loginPassword = value; }
        }

        private string realName;                        ////用户实名
        public string RealName
        {
            get { return realName; }
            set { realName = value; }
        }

        private string sex;                             //用户性别 
        public string Sex
        {
            get { return sex; }
            set { sex = value; }
        }

        private string mobilePhone;                     //用户移动电话
        public string MobilePhone
        {
            get { return mobilePhone; }
            set { mobilePhone = value; }
        }

        private string telephony;                       //用户固定电话
        public string Telephony
        {
            get { return telephony; }
            set { telephony = value; }
        }

        private string email;                           //用户电子邮件
        public string Email
        {
            get { return email; }
            set { email = value; }
        }

        private string qq;                              //用户QQ号码
        public string QQ
        {
            get { return qq; }
            set { qq = value; }
        }

        private string officeAddress;                   //用户工作地址
        public string OfficeAddress
        {
            get { return officeAddress; }
            set { officeAddress = value; }
        }

        private string homeAddress;                     //用户家庭住址
        public string HomeAddress
        {
            get { return homeAddress; }
            set { homeAddress = value; }
        }

        private string lastLoginTime;                 //最后登录系统的时间
        public string LastLoginTime
        {
            get { return lastLoginTime; }
            set { lastLoginTime = value; }
            }

        private decimal createUserID = -1;                   //谁创建的当前资料
        public decimal CreateUserID
        {
            get { return createUserID; }
            set { createUserID = value; }
        }

        private string createDateTime;                  //创建时间是何时
        public string CreateDateTime
        {
            get { return createDateTime; }
            set 
            { 
                createDateTime = value; 
            }
        }

        private decimal modifyUserID = -1;              //谁修改的当前资料
        public decimal ModifyUserID
        {
            get { return modifyUserID; }
            set { modifyUserID = value; }
        }

        private string modifyDateTime;                //修改时间
        public string ModifyDateTime
        {
            get { return modifyDateTime; }
            set
            {
                modifyDateTime = value;
            }
        }

        private decimal recordStatus = -1;                    //记录用户状态
        public decimal RecordStatus
        {
            get { return recordStatus; }
            set { recordStatus = value; }
        }

        private string backup1;                         //备用字段
        public string Backup1
        {
            get { return backup1; }
            set { backup1 = value; }
        }

        private string backup2;                         //备用字段
        public string Backup2
        {
            get { return backup2; }
            set { backup2 = value; }
        }

        private string backup3;                         //备用字段
        public string Backup3
        {
            get { return backup3; }
            set { backup3 = value; }
        }

        private string backup4;                         //备用字段
        public string Backup4
        {
            get { return backup4; }
            set { backup4 = value; }
        }

        private string backup5;                         //备用字段
        public string Backup5
        {
            get { return backup5; }
            set { backup5 = value; }
        }
    }

    //用于删除重复值:仅仅对比了UserID所以只用在UserManagerRelation的ddlControlledUserListSelect_SelectedIndexChanged事件方法内.
    public class Entity_USER_User_Comparer : IEqualityComparer<Entity_USER_User>
    {
        public bool Equals(Entity_USER_User x, Entity_USER_User y)
        {
            //分别对属性进行比较
            if (x.UserID==y.UserID && x.Roles==y.Roles && x.Depts==y.Depts && 
                x.LoginName==y.LoginName && x.LoginPassword==y.LoginPassword && 
                x.RealName==y.RealName && x.Sex==y.Sex && x.MobilePhone==y.MobilePhone && 
                x.Telephony==y.Telephony && x.Email==y.Email && x.QQ==y.QQ && 
                x.OfficeAddress==y.OfficeAddress && x.HomeAddress==y.HomeAddress && 
                x.LastLoginTime==y.LastLoginTime && x.CreateUserID==y.CreateUserID && 
                x.CreateDateTime==y.CreateDateTime && x.ModifyUserID==y.ModifyUserID &&
                x.ModifyDateTime==y.ModifyDateTime && x.RecordStatus==y.RecordStatus &&
                x.Backup1==y.Backup1 && x.Backup2==y.Backup2 && x.Backup3==y.Backup3 && 
                x.Backup4==y.Backup4 && x.Backup5==y.Backup5)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public int GetHashCode(Entity_USER_User obj)
        {
            return 0;
        }
    }
}
